package cn.wfu.rlrjds.container;

import org.apache.commons.lang.StringUtils;

/**
 * 用来获取业务层对象
 * 
 * @author MGL
 * 
 */
public class ServiceProvinder {
	private static ServiceProvinderCore sc;
	static {
		sc = new ServiceProvinderCore();
		sc.load("qlrjds-servlet.xml");
	}

	public static Object getService(String beanName) {
		if (StringUtils.isBlank(beanName)) {
			throw new RuntimeException("您访问的服务名称不能为空");
		}

		Object bean = null;
		if (sc.context.containsBean(beanName)) {
			bean = sc.context.getBean(beanName);
		}

		if (bean == null) {
			throw new RuntimeException("您访问的服务名称[" + beanName + "]不存在");
		}

		return bean;
	}
}
